//
//  MJ_DetailMainController.m
//  UEAssistant
//
//  Created by mac on 2018/1/15.
//  Copyright © 2018年 youyixinxi. All rights reserved.
//

#import "MJ_DetailMainController.h"
#import "DetailsViewController.h"
#import "FilesViewController.h"
#import "TickersViewController.h"
#import "ToolspViewController.h"
#import "UIImage+Color.h"
@interface MJ_DetailMainController ()<VTMagicViewDelegate,VTMagicViewDataSource>

@end

@implementation MJ_DetailMainController

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setShadowImage:[UIImage createImageWithColor:[UIColor clearColor]]];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar setShadowImage:[UIImage createImageWithColor:lineMainColor]];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = detailsModel.productName;
    self.magicView.navigationColor = [UIColor whiteColor];
    self.magicView.sliderColor = mainColor;
    self.magicView.layoutStyle = VTLayoutStyleDivide;
    self.magicView.switchStyle = VTSwitchStyleDefault;
    self.magicView.sliderStyle = VTSliderStyleBubble;
    self.magicView.bubbleInset = UIEdgeInsetsMake(5, 15, 5, 15);
    self.magicView.bubbleRadius = 13;
    self.magicView.navigationHeight = 40.f;
    self.magicView.separatorColor = lineMainColor;
    self.magicView.needPreloading = NO;
    self.magicView.backgroundColor = [UIColor whiteColor];
    self.magicView.scrollEnabled = NO;
    [self.magicView reloadData];
}
//返回标题
- (NSArray<NSString *> *)menuTitlesForMagicView:(VTMagicView *)magicView {
    return @[@"详情",@"文件",@"工具",@"订单"];
}
//返回按钮设置
- (UIButton *)magicView:(VTMagicView *)magicView menuItemAtIndex:(NSUInteger)itemIndex
{
    static NSString *itemIdentifier = @"itemIdentifier";
    UIButton *menuItem = [magicView dequeueReusableItemWithIdentifier:itemIdentifier];
    if (!menuItem) {
        menuItem = [UIButton buttonWithType:UIButtonTypeCustom];
        [menuItem setTitleColor:[UIColor colorWithHexString:@"#666666"] forState:UIControlStateNormal];
        [menuItem setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
        menuItem.titleLabel.font = [UIFont systemFontOfSize:14];
    }
    return menuItem;
}
//返回controller
- (UIViewController *)magicView:(VTMagicView *)magicView viewControllerAtPage:(NSUInteger)pageIndex {

    if (pageIndex == 0) {
        static NSString *detailId = @"DetailsViewController";
        DetailsViewController *vc = [magicView dequeueReusablePageWithIdentifier:detailId];
        if (!vc) {
            vc = [[DetailsViewController alloc] init];
        }
        return vc;
    }else if (pageIndex == 1) {
        
        static NSString *fileId = @"FilesViewController";
        FilesViewController *vc = [magicView dequeueReusablePageWithIdentifier:fileId];
        if (!vc) {
            vc = [[FilesViewController alloc] init];
        }
        return vc;
        
    }else if (pageIndex == 2) {
        
        static NSString *toolId = @"ToolspViewController";
        ToolspViewController *vc = [magicView dequeueReusablePageWithIdentifier:toolId];
        if (!vc) {
            vc = [[ToolspViewController alloc] init];
        }
        return vc;
        
    }else{
        static NSString *ticketId = @"TickersViewController";
        TickersViewController *vc = [magicView dequeueReusablePageWithIdentifier:ticketId];
        if (!vc) {
            vc = [[TickersViewController alloc] init];
        }
        return vc;
    }
}

@end
